package com.training.java.core.collections.car.pre15;

/**
 * LapTop class has company,model,os,processor attributes.
 * 
 * @author Satya
 * 
 */
public class LapTop {
	private String company;
	private String model;
	private String os;
	private String processor;

	public LapTop(String company, String model, String processor, String os)

	{
		this.company = company;
		this.model = model;
		this.processor = processor;
		this.os = os;
	}

	public LapTop() {

	}

	public String getOs() {
		return os;
	}

	public void setOs(String os) {
		this.os = os;
	}

	public String getCompany() {
		return company;
	}

	public String getModel() {
		return model;
	}

	public String getProcessor() {
		return processor;
	}

	/**
	 * Here the requirement is "If make,model are equal the cars are equal"
	 * finding the equality by overriding the equals and hashCode
	 */

	@Override
	public boolean equals(Object obj) {

		// checking the parameter is real time object or not.
		// if it is not real object, it should
		// return False.

		if (obj instanceof LapTop)

		{
			LapTop laptop2 = (LapTop) obj; // Casting
			return this.company.equals(laptop2.company)
					&& this.model.equals(laptop2.model);

		} else {
			return false;

		}

	}// end of equals method

	// Overriding the hashCode

	@Override
	public int hashCode() {
		return company.hashCode() + model.hashCode() + os.hashCode()
				+ processor.hashCode();
	}

}
